package com.opencee.common.security.oauth2;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.provider.TokenRequest;

/**
 * 自定义TokenGranter 认证处理器
  * @author yadu
 */
public interface CustomTokenAuthenticationHandler {


    /**
     * 进行预处理
     *
     * @param tokenRequest 请求
     * @throws Exception
     */
    void prepare(TokenRequest tokenRequest) throws Exception;

    /**
     * 处理认证
     *
     * @param tokenRequest
     * @throws AuthenticationException
     * @return 用户信息
     */
    UserDetails authenticate(TokenRequest tokenRequest) throws AuthenticationException;

    /**
     * 认证类型
     *
     * @return
     */
    String grantType();
}
